<?php

include_once('superheader.php');
session_unset();
$m = new Mongo();


$db = $m->EMU;

$collection = $db->users;

$userQuery = array( 'password' => $_POST['password'], 'user' =>  $_POST['username']);

$cursor = $collection->findOne($userQuery);


if($cursor == NULL)
{

	$_SESSION['fail'] = "fail";
	Header("Location: index.php?login=fail");
}
else
{
	$_SESSION['username'] = $_POST['username'];
	$_SESSION['role'] = $cursor['role'];
	Header("Location: landing.php");
}
?>